import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import ElementPlus from 'unplugin-element-plus/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import path from 'path'

export default defineConfig({
  plugins: [
      vue(),
      AutoImport({
          imports: ['vue'],
          resolvers: [
              ElementPlusResolver(),
          ],
      }),
      Components({
          resolvers: [
              ElementPlusResolver(),
          ],
      }),
      ElementPlus({
          // options
      }),
  ],
    server: {
        port: 8028,
        // open: true,
        proxy: {
            '/api': {
                target: 'http://localhost:8018',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, ''),
            },
        },
    },
    css: {
        preprocessorOptions: {
            scss: {
                api: 'modern-compiler',
            },
        },
    },
    resolve: {
        alias: {
            '@': path.resolve(__dirname, 'src')
        }
    }
})
